-- is_need_flush_dns
--
local import = import
---@type behavior_ret
local bret = import("bt/bt_plugin/behavior3/behavior_ret")

local M = {
    name = "is_need_flush_dns",
    type = "Condition",
    desc = "是否需要刷新dns",
    args = {
        --{ "str", "string", "变量描述" },
    },
    output = {  },
}

function M.run(node, env, value)
    -- 检查hosts文件大小
    local hostsPath = "C:\\Windows\\System32\\drivers\\etc\\hosts" -- 替换为你的hosts文件路径
    local file = io.open(hostsPath, "rb")
    if file then
        local size = file:seek("end")
        file:close()
        if size < 10240 then -- 10KB
            return bret.SUCCESS
        end
    end
    -- node.args.str
    return bret.FAIL
end

return M
